﻿using KimPhongCRM.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace KimPhongCRM.Controllers
{
    [PermissionFilter]
    public class PopupController : Controller
    {
        KimPhongCRM.Models.Entities db = new Models.Entities();

        //
        // GET: /Popup/

        public ActionResult Index()
        {
            return View();
        }
        public JsonResult SetPopup(string table, long id)
        {
            Dictionary<string,object> dicPopup = new Dictionary<string,object>();
            string strView = "";
            ViewData["popupdata"] = "";
            switch (table)
            {
                case "KhachHang":
                    {
                        strView = "KhachHang";
                        tblKhachHang tblkhachhang = db.tblKhachHangs.Find(id);
                        ViewData["popupdata"] = tblkhachhang;
                        break;
                    }
                case "Tour":
                    {
                        strView = "Tour";
                        tblTour tbltour = db.tblTours.Find(id);
                        ViewData["popupdata"] = db.tblTours.ToList();
                        break;
                    }
            }
            dicPopup.Add("strView", strView);
            dicPopup.Add("id", id);
            return Json(dicPopup, JsonRequestBehavior.AllowGet);
        }

    }
}
